package com.scommunity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scommunity.admin.vo.OwnerQO;
import com.scommunity.domain.Owner;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
@Transactional(rollbackFor = Exception.class)
public interface OwnerMapper extends BaseMapper<Owner> {
    List<Owner> findPageInfoByCondition(OwnerQO ownerQO);

    @Select("select * from sc_owner")
    List<Owner> findAll();

    @Insert("insert into sc_owner values(#{ownerId},#{ownerName},#{ownerGender},#{ownerPhone},#{ownerIdcard},0,#{userId})")
    void add(Owner owner);

    void update1(Owner owner);

    @Delete("delete from sc_owner where owner_id = #{id}")
    void del(String id);

    @Select("select owner_status from sc_owner where owner_id = #{id}")
    int getStatuseById(String id);

    @Insert("insert into house_owner values(#{houseId},#{ownerId})")
    void addOwnerHouse(String ownerId, String houseId);

    @Delete("delete from house_owner where house_id = #{houseId} and owner_id = #{ownerId}")
    void delOwnerHouse(String ownerId, String houseId);

    @Update("update sc_owner set owner_status = #{status} where owner_id = #{id}")
    void updateHouseStatusById(String id, String status);
}
